package csc.fresher.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import csc.fresher.commons.EncryptMD5;
import csc.fresher.dao.SystemUserDao;
import csc.fresher.entity.SystemUser;

@Service
public class SystemLoginServiceImpl implements SystemLoginService{

	@Autowired
	private SystemUserDao systemUserDao;

	
	

	@Override
	public SystemUser getSystemUser(String userName, String password) {
		List<SystemUser> systemUsers = systemUserDao.getSystemUser();
		for (SystemUser systemUser : systemUsers) {
			if( systemUser.getUserName().equals(userName)
					&& systemUser.getPassWord().equals(EncryptMD5.md5(password))){
				return systemUser;
			}
		}
		return null;
	}

	public void setSystemUserDao(SystemUserDao systemUserDao) {
		this.systemUserDao = systemUserDao;
	}
	
	
}
